import storage from 'good-storage';
const localkey = "_wiki_user_"
export const getlocalstorage = function(){//获取本地缓存
  let val = storage.get(localkey,{});
  return val;
}
export const setlocalstorage = function(val){//保存本地缓存
  storage.set(localkey,val) 
}

export const removelocalstorage = function(){
  storage.remove(localkey)
}

export const gettime = (time)=>{
  let d = new Date(time)
  let D = d.getDate();
  let M = d.getMonth() + 1;
  let Y = d.getFullYear();
  let h = d.getHours();
  let m = d.getMinutes();
  
  let n = new Date()
  let nD = n.getDate();
  let nM = n.getMonth() + 1;
  let nY = n.getFullYear();
  let nh = n.getHours();
  let nm = n.getMinutes();
  if(h< 10){
    h = '0'+h
  }
  if(m<10){
    m = '0'+m
  }
  if(D == nD && M == nM && Y == nY){
    return `${h}:${m}`
  }else if( M == nM && Y == nY && nD-D ==1){
    return `昨天${h}:${m}`
  }else{
    return ` ${Y}/${M}/${D} ${h}:${m}`
  }
}
